﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgFirma.aspx.cs" Inherits="EGuayas.Web.Licenciamiento.dma.pgFirma" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="~/Licenciamiento/dma/wucFirma.ascx" TagPrefix="uc1" TagName="wucFirma" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link  href="~/Resources/css/Style.css"  rel="stylesheet" />
    <!-- Load Ext JS --> 
    <script src="../../Resources/js/Global.js"></script>
   <script>
       var pgFn = new Object();
       pgFn.searchFieldTriggerClick = function (field, trigger, index) {
           try {
               var me = field,
                   store = me.up("grid").getStore(),
                   value = me.getValue();

               if (index == 0) {
                   me.setValue('');
                   store.clearFilter();
                   store.load();
                   trigger.hide();
                   pgFn.updateTotalCount(me.up("grid"), -1);

               }   
               else {
                   if (value.length > 0) {
                     
                       store.filter('Nombre', value);
                       store.load();
                       me.getTrigger(0).show();
                       pgFn.updateTotalCount(me.up("grid"), store.getCount());
                   }
               }
              
           } catch (jsbug) {
               AppGlobalJs.showBug("pgFn.searchFieldTriggerClick : " + jsbug)
           }
       };

       pgFn.onSpecialKey = function (field, e) {
           try {
               if (e.getKey() === e.ENTER) {
                   pgFn.searchFieldTriggerClick(field, null, 1);
                   e.stopEvent();
               }
           } catch (jsbug) {
               AppGlobalJs.showBug("pgFn.onSpecialKey: " + jsbug)
           }
       };
       pgFn.updateTotalCount= function (me,n) {
           try {
               var objStatus = me.down('#status');
               if (n == -1) {
                   objStatus.hide();
               }
               else {
                   if (objStatus.isVisible() == false)
                       objStatus.show();
                   objStatus.update({ count: n });
               }
           } catch (jsbug) {
               AppGlobalJs.showBug("pgFn.updateTotalCount: " + jsbug)
           }
       };
  </script>
</head>
<body>  
    <form id="Form1" runat="server"> 
        <uc1:wucFirma runat="server" ID="wucFirma" />
        <ext:ResourceManager ID="pgIdCategManager" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout" >
         <Items>
            <ext:FormPanel ID="FormPanel3" runat="server" Region="Center" Layout="VBoxLayout" >
                        <LayoutConfig>
                                <ext:VBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
            <Items>
                 <ext:FormPanel
                                ID   ="frmDetail"
                                runat   ="server" 
                                Flex    ="1"
                                Height  ="490"
                                Layout      ="FitLayout"
                                BodyBorder  ="1"                                  
                                Hidden   ="true">  
                                <TopBar>
                                            <ext:Toolbar ID="Toolbar2" runat="server">
                                                <Items>
                                                  <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                                    <ext:Button 
                                                        ID    ="btnForm"
                                                        runat ="server" 
                                                        Text  ="Ver Documentos" 
                                                        Icon  ="ShapeSquareGo"
                                                        OnClientClick="pgFn.ClosePanel();">                                            
                                                        <Listeners>                     
                                                        </Listeners>
                                                    </ext:Button>
                                                  
                                                </Items>
                                            </ext:Toolbar>
                                </TopBar>
                                 <Items> 
                                           <ext:Hidden Text="" ID="hdDocViewId"   Name="Id"  runat  ="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdDocViewRuta" Name="Ruta"       runat="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdTablaInfo"   Name="TablaInfo"  runat  ="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdDocIdAud"    Name="AuditoriaId"  runat  ="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdExpedienteId" Name="ExpedienteId" runat  ="server"></ext:Hidden>
                                           <ext:TabPanel ID="TabPanelGlobal" runat="server"  TabPosition="Left"
                                                EnableTabScroll="true">
                                                <Items> 
                                                    <ext:Panel ID ="tab1FrmDetail" runat="server" Title="Información del documento"  Layout="AnchorLayout"
                                                     ButtonAlign ="Center" >
                                                            <Items></Items>
                                                            <Buttons>
                                                                    <ext:Button ID="btnComentario" runat="server" Text="Comentario"  Hidden="true">
                                                                           <Listeners>
                                                                                 <Click Handler="AppGlobalJs.showWin(#{winComentario});" />
                                                                            </Listeners>  
                                                                    </ext:Button>
                                                                    <ext:Button ID="btnFirma" runat="server" Text="Firmar">                                                                       
                                                                         <Listeners>
                                                                                 <Click Handler="pgFn.showWinFirma();" />
                                                                          </Listeners>  
                                                                    </ext:Button>
                                                            </Buttons>
                                                    </ext:Panel>
                                                    <ext:Panel ID="tab2FrmDetail" runat="server" Title="Anexos"  Layout="AnchorLayout">
                                                        <Items></Items> 
                                                       </ext:Panel> 
                                                        </Items>
                                            </ext:TabPanel>                    
                                 </Items>
                             
               </ext:FormPanel>
               <ext:TabPanel ID="frmSettings" runat="server">
               <Items>
                  <ext:FormPanel ID="FormPanel1" runat="server" Title="Documentos por firmar"  Icon="FolderPageWhite">
                       
                        <Items>                           
                             <ext:FormPanel
                                ID     ="frmSettings1"
                                runat  ="server" 
                              
                                
                                Margins     ="5 5 5 5" 
                                Flex        ="1"
                                Layout      ="FitLayout"
                                BodyBorder  ="0"                          
                                Collapsible ="true">                           
                                <Items>
                                            <ext:GridPanel
                                                ID="gpDocumentosLoad"                                              
                                                runat="server"                                           
                                                Height="490">
                                                <Store>
                                                    <ext:Store ID="stoDoc" runat="server" PageSize="25"  OnReadData="MyData_Refresh" RemotePaging="false">
                                                        <Model>
                                                            <ext:Model ID="Model2" runat="server" IDProperty="Id">
                                                                <Fields>
                                                                    <ext:ModelField Name="FaseLicId" Type="String" />
                                                                    <ext:ModelField Name="FechaCreacion" Type="Date" />
                                                                    <ext:ModelField Name="FechaFirmado" Type="Date" />
                                                                    <ext:ModelField Name="Firmado" Type="String" />
                                                                    <ext:ModelField Name="Id" Type="String" />
                                                                    <ext:ModelField Name="Descripcion" Type="String" />
                                                                    <ext:ModelField Name="Nombre" Type="String" />
                                                                    <ext:ModelField Name="PersonaId" Type="String" />
                                                                    <ext:ModelField Name="PersonaNombres" Type="String" />                                                                    
                                                                    <ext:ModelField Name="Referencia" Type="String" />
                                                                    <ext:ModelField Name="RequiereFirmar" Type="String" />
                                                                    <ext:ModelField Name="Ruta" Type="String" />
                                                                    <ext:ModelField Name="TipoDocumento" Type="String" />
                                                                    <ext:ModelField Name="SubirNuevo" Type="String" />
                                                                    <ext:ModelField Name="Version" Type="Int" />
                                                                    <ext:ModelField Name="ExpedienteId" Type="String" />
                                                                    <ext:ModelField Name="AuditoriaId" Type="String" />
                                                                    <ext:ModelField Name="TablaInfo" Type="String" />
                                                                </Fields>
                                                            </ext:Model>
                                                          
                                                        </Model>                                      
                                                            <Listeners>
                                                             
                                                            </Listeners>
                                                    </ext:Store>
                                                </Store>
                                                <ColumnModel ID="ColumnModel2" runat="server">
                                                    <Columns>
                                                        <ext:Column  runat="server" Text="Id" DataIndex="Id" Flex="1" Hidden="true"/>
                                                      
                                                        <ext:Column  runat="server" Text="Nombre"  DataIndex="Nombre"  RightCommandAlign="true" Flex="1" />
                                                      
                                                        <ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server" Width="80" Text="Estado" Align="Center">
                                                            <Commands>
                                                                <%-- 
                                                                 <ext:ImageCommand CommandName="IconComment" Icon="CommentAdd" Text="&nbsp;Comentado">
                                                                    <ToolTip Text="Documento comentado"></ToolTip>
                                                                    </ext:ImageCommand>
                                                               --%>
                                                                <ext:ImageCommand CommandName="IconSign" Icon="ReportKey" Text="&nbsp;Firmado">
                                                                    <ToolTip Text="Documento firmado"></ToolTip>
                                                                    </ext:ImageCommand>
                                                            </Commands>
                                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                                          
                                                            <Listeners>
                                                                <Command Handler="pgFn.ShowEstado(record);" />
                                                            </Listeners>
                                                        </ext:ImageCommandColumn>
                                                       
                                                        <ext:Column  runat="server" Text="Decripción" DataIndex="Descripcion" /> 
                                                        <ext:DateColumn runat="server" Text="Fecha" Width="95" DataIndex="FechaCreacion" Format="dd-m-yy" />
                                                      
                                                        <ext:Column ID="Column2"  runat="server">
                                                            <Commands>
                                                                <ext:ImageCommand CommandName="View" Icon="MagnifierZoomIn" Text="Vizualizar" >
                                                                    <ToolTip Text="Vizualizar" />
                                                                </ext:ImageCommand>
                                                            </Commands>
                                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                                            <Listeners>
                                                                  <Command Handler="pgFn.ShowViewDetailPanel(record,'N');" />
                                                            </Listeners>
                                                        </ext:Column>
                                                       <ext:Column ID="Column1"  runat="server">
                                                            <Commands>
                                                                <ext:ImageCommand CommandName="Sign" Icon="PageWhiteStack" Text="Firmar">
                                                                    <ToolTip Text="Firmar documento" />
                                                                </ext:ImageCommand>
                                                            </Commands>
                                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                                            <Listeners>
                                                                  <Command Handler="pgFn.ShowViewDetailPanel(record,'S');" />
                                                            </Listeners>
                                                        </ext:Column>                                                                                 
                                                    </Columns>                                                    
                                                </ColumnModel>
                                                <Plugins>
                                                    <ext:RowExpander ID="RowExpander1" runat="server">
                                                        <Loader ID="Loader1" runat="server" DirectMethod="#{DirectMethods}.GetSubDoc" Mode="Component">
                                                            <LoadMask ShowMask="true" />
                                                            <Params>
                                                                <ext:Parameter Name="id" Value="this.record.data.Referencia" Mode="Raw" />
                                                                <ext:Parameter Name="tabla" Value="this.record.data.TablaInfo" Mode="Raw" />
                                                            </Params>
                                                        </Loader>
                                                    </ext:RowExpander>
                                                </Plugins> 
                                                 <Features>
                                                    <ext:GridFilters runat="server" ID="GridFilters1" Local="true"  MenuFilterText="Filtrar por">
                                                        <Filters>
                                                            <ext:StringFilter DataIndex="Nombre" EmptyText="Nombre" />
                                                            <ext:StringFilter DataIndex="Descripcion"  EmptyText="Descripción"/> 
                                                                <ext:DateFilter DataIndex="FechaCreacion" AfterText="Despues de" BeforeText="Antes de"  OnText="En">
                                                                <DatePickerOptions runat="server" TodayText="Ahora" />
                                                            </ext:DateFilter>                                                           
                                                        </Filters>
                                                    </ext:GridFilters>
                                                </Features>
                                                <View>
		                                                <ext:GridView ID="GridView1" runat="server" StripeRows="true" />                   
		                                        </View>            
		                                        <BottomBar>
		                                                 <ext:PagingToolbar ID="PagingToolbar1" runat="server">
			                                               <Items>
				                                                <ext:Label ID="Label1" runat="server" Text="Filas por página:" />
				                                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
				                                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
					                                                <Items>
						                                                <ext:ListItem Text="5" />
						                                                <ext:ListItem Text="10" />
						                                                <ext:ListItem Text="15" />
						                                                <ext:ListItem Text="20" />
						                                                <ext:ListItem Text="25" />
						                                                <ext:ListItem Text="30" />
						                                                <ext:ListItem Text="35" />
						                                                <ext:ListItem Text="40" />
						                                                <ext:ListItem Text="45" />
						                                                <ext:ListItem Text="50" />
					                                                </Items>
					                                                <SelectedItems>
						                                                <ext:ListItem Value="25" />
					                                                </SelectedItems>
					                                                <Listeners>
						                                                <Select Handler="#{gpDocumentosLoad}.store.pageSize = parseInt(this.getValue(), 10); #{gpDocumentosLoad}.store.reload();" />
					                                                </Listeners>
				                                                </ext:ComboBox>
			                                                </Items>
		                                                </ext:PagingToolbar>
		                                                </BottomBar>                                                            
                                                  <DockedItems>
                                                    <%--  
                                                    <ext:Toolbar ID="Toolbar1" runat="server" Dock="Top">
                                                        <Items>
                                                            <ext:TriggerField ID="TriggerField1" 
                                                                runat="server"
                                                                Width="400"                                                                 
                                                                FieldLabel="Buscar"
                                                                LabelWidth="50">
                                                                <Triggers>
                                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                                    <ext:FieldTrigger Icon="Search" />
                                                                </Triggers>
                                                                <Listeners>
                                                                    <TriggerClick Fn="pgFn.searchFieldTriggerClick" />
                                                                    <SpecialKey Fn="pgFn.onSpecialKey" />
                                                                </Listeners>
                                                            </ext:TriggerField>                        
                                                            <ext:ToolbarFill />
                                                            <ext:Component ID="Component1" 
                                                                runat="server"
                                                                ItemID="status"
                                                                StyleSpec="margin-right:5px;">
                                                                <Tpl>
                                                                    <Html>
                                                                       Datos Encontrados: {count}
                                                                    </Html>
                                                                </Tpl>
                                                            </ext:Component>
                                                        </Items>
                                                    </ext:Toolbar>
                                                    --%>
                                                </DockedItems>
                                            </ext:GridPanel>
                               </Items>                                  
                            </ext:FormPanel>                           
                            
                       </Items>
                       <BottomBar>
                            <ext:StatusBar 
                                ID="StatusBar2" 
                                runat="server"
                                StatusAlign="Left">
                                <Items>                                
                                    <ext:ToolbarTextItem ID="ToolbarTextItem1" runat="server" Text="" Cls="ux-bold-text-item"  Margin="15"/>
                                </Items>
                            </ext:StatusBar>
                        </BottomBar>
                </ext:FormPanel>
                <ext:FormPanel
                ID     ="frmSettings2"
                runat  ="server" 
                Title  ="Documentos firmados" 
                Icon   ="PageGear"
                Margins     ="5 5 5 5" 
                Flex        ="1"
                Layout      ="FitLayout"
                BodyBorder  ="0"                          
                Collapsible ="true">                           
                <Items>
                            <ext:GridPanel
                                ID ="gpFirmados"                                              
                                runat="server"                                           
                                Height="490">
                                <Store>
                                    <ext:Store ID="Store1" runat="server" PageSize="25"  OnReadData="MyData_Refresh" RemotePaging="false">
                                        <Model>
                                            <ext:Model ID="Model1" runat="server" IDProperty="Id">
                                                <Fields>
                                                    <ext:ModelField Name="FaseLicId" Type="String" />
                                                    <ext:ModelField Name="FechaCreacion" Type="Date" />
                                                    <ext:ModelField Name="FechaFirmado" Type="Date" />
                                                    <ext:ModelField Name="Firmado" Type="String" />
                                                    <ext:ModelField Name="Id" Type="String" />
                                                    <ext:ModelField Name="Descripcion" Type="String" />
                                                    <ext:ModelField Name="Nombre" Type="String" />
                                                    <ext:ModelField Name="PersonaId" Type="String" />
                                                    <ext:ModelField Name="PersonaNombres" Type="String" />                                                                    
                                                    <ext:ModelField Name="Referencia" Type="String" />
                                                    <ext:ModelField Name="RequiereFirmar" Type="String" />
                                                    <ext:ModelField Name="Ruta" Type="String" />
                                                    <ext:ModelField Name="TipoDocumento" Type="String" />
                                                    <ext:ModelField Name="SubirNuevo" Type="String" />
                                                    <ext:ModelField Name="Version" Type="Int" />
                                                    <ext:ModelField Name="ExpedienteId" Type="String" />
                                                    <ext:ModelField Name="AuditoriaId" Type="String" />
                                                    <ext:ModelField Name="TablaInfo" Type="String" />
                                                </Fields>
                                            </ext:Model>
                                                          
                                        </Model>                                      
                                            <Listeners>
                                                             
                                            </Listeners>
                                    </ext:Store>
                                </Store>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column ID="Column3"  runat="server" Text="Id" DataIndex="Id" Flex="1" Hidden="true"/>
                                                      
                                        <ext:Column ID="Column4"  runat="server" Text="Nombre"  DataIndex="Nombre"  RightCommandAlign="true" Flex="1" />
                                                      
                                        <ext:ImageCommandColumn ID="ImageCommandColumn2" runat="server" Width="80" Text="Estado" Align="Center">
                                            <Commands>
                                                              
                                                <ext:ImageCommand CommandName="IconSign" Icon="ReportKey" Text="&nbsp;Firmado">
                                                    <ToolTip Text="Documento firmado"></ToolTip>
                                                    </ext:ImageCommand>
                                            </Commands>
                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                                          
                                            <Listeners>
                                                <Command Handler="pgFn.ShowEstado(record);" />
                                            </Listeners>
                                        </ext:ImageCommandColumn>
                                                       
                                        <ext:Column ID="Column5"  runat="server" Text="Decripción" DataIndex="Descripcion" /> 
                                        <ext:DateColumn ID="DateColumn1" runat="server" Text="Fecha" Width="95" DataIndex="FechaCreacion" Format="dd-m-yy" />
                                                      
                                        <ext:Column ID="Column6"  runat="server">
                                            <Commands>
                                                <ext:ImageCommand CommandName="View" Icon="MagnifierZoomIn" Text="Vizualizar" >
                                                    <ToolTip Text="Vizualizar" />
                                                </ext:ImageCommand>
                                            </Commands>
                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                            <Listeners>
                                                    <Command Handler="pgFn.ShowViewDetailPanel(record,'N');" />
                                            </Listeners>
                                        </ext:Column>
                                                                                                                                     
                                    </Columns>                                                    
                                </ColumnModel>
                                <Plugins>
                                    <ext:RowExpander ID="RowExpander2" runat="server">
                                        <Loader ID="Loader2" runat="server" DirectMethod="#{DirectMethods}.GetSubDoc" Mode="Component">
                                            <LoadMask ShowMask="true" />
                                            <Params>
                                                <ext:Parameter Name="id" Value="this.record.data.Referencia" Mode="Raw" />
                                                <ext:Parameter Name="tabla" Value="this.record.data.TablaInfo" Mode="Raw" />
                                            </Params>
                                        </Loader>
                                    </ext:RowExpander>
                                </Plugins> 
                                    <Features>
                                    <ext:GridFilters runat="server" ID="GridFilters2" Local="true"  MenuFilterText="Filtrar por">
                                        <Filters>
                                            <ext:StringFilter DataIndex="Nombre" EmptyText="Nombre" />
                                            <ext:StringFilter DataIndex="Descripcion"  EmptyText="Descripción"/> 
                                                <ext:DateFilter DataIndex="FechaCreacion" AfterText="Despues de" BeforeText="Antes de"  OnText="En">
                                                <DatePickerOptions runat="server" TodayText="Ahora" />
                                            </ext:DateFilter>                                                           
                                        </Filters>
                                    </ext:GridFilters>
                                </Features>
                                <View>
		                                <ext:GridView ID="GridView2" runat="server" StripeRows="true" />                   
		                        </View>            
		                        <BottomBar>
		                                    <ext:PagingToolbar ID="PagingToolbar2" runat="server">
			                                <Items>
				                                <ext:Label ID="Label2" runat="server" Text="Filas por página:" />
				                                <ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" Width="10" />
				                                <ext:ComboBox ID="ComboBox2" runat="server" Width="80">
					                                <Items>
						                                <ext:ListItem Text="5" />
						                                <ext:ListItem Text="10" />
						                                <ext:ListItem Text="15" />
						                                <ext:ListItem Text="20" />
						                                <ext:ListItem Text="25" />
						                                <ext:ListItem Text="30" />
						                                <ext:ListItem Text="35" />
						                                <ext:ListItem Text="40" />
						                                <ext:ListItem Text="45" />
						                                <ext:ListItem Text="50" />
					                                </Items>
					                                <SelectedItems>
						                                <ext:ListItem Value="25" />
					                                </SelectedItems>
					                                <Listeners>
						                                <Select Handler="#{gpDocumentosLoad}.store.pageSize = parseInt(this.getValue(), 10); #{gpDocumentosLoad}.store.reload();" />
					                                </Listeners>
				                                </ext:ComboBox>
			                                </Items>
		                                </ext:PagingToolbar>
		                                </BottomBar>                                                            
                                    <DockedItems>
                                                 
                                </DockedItems>
                            </ext:GridPanel>
                    </Items>
                                  
            </ext:FormPanel>   
                </Items>        
           </ext:TabPanel> 
           <ext:Window 
            ID="winComentario" 
            runat="server"            
            Icon="NoteEdit"
            Height="185" 
            Width="350"
            ButtonAlign="Center"
            BodyStyle="background-color: #fff;" 
            BodyPadding="5"            
            hidden="true" 
            closeaction="Hide">
            <Content>
                <ext:FormPanel 
                    ID="forPanelComentario"                   
                    Border="false"
                    runat="server"
                    Width="330"            
                    BodyPadding="5"
                    Layout="Form">
                    <FieldDefaults LabelWidth="75" LabelPad="20" LabelSeparator="" />
                    <Items>   
                         <ext:Panel ID="Panel2" runat="server" Border="false" Layout="Form" ColumnWidth=".5" LabelAlign="Top">
                            <Defaults>
                                <ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
                                <ext:Parameter Name="MsgTarget" Value="side" />
                            </Defaults>
                            <Items> 
                                <ext:TextArea ID="txtComentario" runat="server" FieldLabel="Comentario"  AnchorHorizontal="90%" AnchorVertical="100%"></ext:TextArea>
                                    
                            </Items>
                        </ext:Panel>
                    </Items>
                    <Listeners>
                        <ValidityChange Handler="#{btnWinComentariOk}.setDisabled(!valid);" />
                    </Listeners>
                </ext:FormPanel>
            </Content>
            <Buttons>
                <ext:Button ID="btnWinComentariOk" runat="server" Text="Aceptar"  Disabled="true"
                    FormBind="true">
             
                     <DirectEvents>
                        <Click OnEvent="btnComentario_Click"  After="AppGlobalJs.closeWin(#{winComentario})" Before="
                                    if (#{forPanelComentario}.getForm().isValid())
                                    {
                                        return(true);     
                                    }
                                    else
                                    {
                                        Ext.Msg.alert('Error','Campos obligatorio.');
                                        return false;
                                    }" >
				             <ExtraParams>
                                    <ext:Parameter Name="hddTxtComentario" Value="#{txtComentario}.getValue()"   Mode="Raw" />
                                    <ext:Parameter Name="hdExpedienteId" Value="#{hdExpedienteId}.getValue()"   Mode="Raw" />
                                    <ext:Parameter Name="hdDocViewId" Value="#{hdDocViewId}.getValue()"   Mode="Raw" /> 
                             </ExtraParams>	
                            <EventMask ShowMask="True"></EventMask>	    
                        </Click>                          
                   </DirectEvents>
                </ext:Button>
                <ext:Button ID="btnWinComentarioCancel" runat="server" Text="Cancelar"  OnClientClick="AppGlobalJs.closeWin(#{winComentario})">
                    <Listeners>                    
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Listeners>
                <BeforeHide Handler="#{forPanelComentario}.getForm().reset();"></BeforeHide>              
            </Listeners>
        </ext:Window>   
            </Items>
            </ext:FormPanel>
            </Items>
       </ext:Viewport>
    </form>
    <ext:XScript ID="XScript1" runat="server">
        <script  type="text/javascript">
          
            pgFn.myPanel1 = null;
            pgFn.myPanel2 = null;
            pgFn._id1 = "pnlContentUrlDinamic1";
            pgFn._id2 = "pnlContentUrlDinamic2";
            pgFn.getIdContentDinamic1 = function () {
                return (pgFn._id1);
            };
            pgFn.getIdContentDinamic2 = function () {
                return (pgFn._id2);
            };
            //Previsualizacion de ventana
            pgFn.showWinFirma = function () {               
                App.direct.wucDMFirma.ViewDetailsFirma(#{hdTablaInfo}.getValue(),#{hdDocViewId}.getValue(),#{hdDocViewRuta}.getValue(),{
                    success: function (result) {
                        AppGlobalJs.showWin(#{winFirma});
                    },
                    eventMask: {
                        showMask: true,
                        minDelay: 500
                    }
                });
            };
            //Actualizar tab
            pgFn.ReloadTabDinamig = function (url) {
                var tabDinamic= Ext.getCmp('pnlContentUrlDinamic1');
                if (tabDinamic!=null)
                    tabDinamic.load("../../../pgDetailPdf.aspx?idx=" + url);
                Ext.Msg.show({
                    title: 'Aviso',
                    msg: 'Archivo Firmado',
                    minWidth: 200,
                    modal: true,
                    icon: Ext.Msg.INFO,
                    buttons: Ext.Msg.OK
                });
            }
            //Cerrar panel detalles
            pgFn.ClosePanel= function (){
                App.frmDetail.hide();
                //App.frmSettings.expand();
                App.frmSettings.show();
                //               
                if (pgFn.myPanel1 != null) {
                    App.tab1FrmDetail.remove(pgFn.getIdContentDinamic1(), false);
                    pgFn.myPanel1 = null;
                }
                //
                if (pgFn.myPanel != null) {
                    App.tab2FrmDetail.remove(pgFn.getIdContentDinamic2(), false);
                    pgFn.myPanel2 = null;
                }
                //
                App.hdDocViewId.setValue("");
                App.hdDocViewRuta.setValue("");
                App.btnFirma.enable();
                App.btnWinComentariOk.enable();
                App.frmDetail.getForm().reset();
            };
            pgFn.AddPanelUrl = function (myPanelContent,myId, myUrl) {
                var myPanel = myPanelContent.add(new Ext.Panel({
                    id: myId,
                    border: false,
                    anchor: '100% 100%',
                   
                    loader:
                     {
                         loadMask:
                             {
                                 showMask: true
                             },
                         renderer: "frame",
                         url: myUrl
                     },
                    bodyPadding: 6,
                    closable: false,

                }));
                
                return (myPanel);
            };
            //Mostrar panel detalles
            pgFn.ShowViewDetailPanel = function (record,viewBtns) {
                var myUrl = "";
              
                App.frmSettings.hide();
                App.frmDetail.show();
                //App.frmSettings.hide();
                //Url 1
                myUrl = "../../pgDetailPdf.aspx?idx=" + record.get("Ruta");
                pgFn.myPanel1 = pgFn.AddPanelUrl(App.tab1FrmDetail, pgFn.getIdContentDinamic1(), myUrl);
              
                //
                if (record.get("TablaInfo")=="DOCLIC" || record.get("TablaInfo")== "INFDOCLIC")
                    myUrl="../admin/pgDocGlobalLicencias.aspx?Id=" + record.get("ExpedienteId");
                else
                    myUrl="../../Auditoria/admin/pgDocGlobalAuditoria.aspx?Id=" + record.get("ExpedienteId");
                //
                pgFn.myPanel2 = pgFn.AddPanelUrl(App.tab2FrmDetail, pgFn.getIdContentDinamic2(), myUrl);
                App.TabPanelGlobal.setActiveTab(0);
                App.frmDetail.getForm().loadRecord(record);
             

                if (viewBtns == 'N') {
                    //App.btnComentario.hide();
                    App.btnFirma.hide();
                }
                else
                {
                    //App.btnComentario.show();
                    App.btnFirma.show();
                }
               
            };
            pgFn.ShowEstado = function (record) {
                var msg = "<b>Documento:</b>"+record.get("Nombre");
                if (record.get("Firmado") == 'S') {
                    msg += "<br> <p><b>Firmado fecha:</b>" + dateFormat(record.get("FechaFirmado"), "dd-m-yyyy")+"</p>";
                    Ext.Msg.show({
                        title: 'Estado',
                        msg: msg,
                        minWidth: 200,
                        modal: true,
                        icon: Ext.Msg.INFO,
                        buttons: Ext.Msg.OK
                    });
                }
                if (record.get("SubirNuevo") == 'S')
                    App.direct.ViewComentario(record.get("Id"));
               
            };
            //Mostrar y/o ocultar botones de acuerdo a estado de documento
            pgFn.PrepareCommand = function (grid, command, record, row) {
               if (command.command == 'IconSign') {

                    if (record.get("Firmado") == 'N') {
                        command.hidden = true;
                        command.hideMode = 'display'; //you can try 'visibility' also  
                    }
                    else {
                        command.hidden = false;
                        command.hideMode = 'visibility';
                    }


               }
                /*
                if (command.command == 'IconComment') {

                    if (record.get("SubirNuevo") == 'N') {
                        command.hidden = true;
                        command.hideMode = 'display';   
                    }
                    else {
                        command.hidden = false;
                        command.hideMode = 'visibility';
                    }


                }*/
                if (command.command == 'Sign') {

                    if (record.get("Firmado") == 'S') {
                        command.hidden = true;
                        command.hideMode = 'display'; //you can try 'visibility' also  
                    }
                    else {
                        command.hidden = false;
                        command.hideMode = 'visibility';
                    }


                }
                if (command.command == 'View')
                {
                    command.hidden = false;
                    command.hideMode = 'visibility';
                }

            };
       </script>
    </ext:XScript>     
</body>


</html>
